package com.buddies.lottery.ui.lottery.bet.period;

import com.buddies.lottery.base.list.BaseListPresenter;
import com.buddies.lottery.data.BaseObserver;
import com.buddies.lottery.data.DataManager;
import com.buddies.lottery.data.bean.LotteryBetRecord;
import com.buddies.lottery.data.result.PageResult;

import java.util.Map;

public class LotteryPeriodBetRecordPresenter extends BaseListPresenter<LotteryPeriodBetRecordContract.View> implements LotteryPeriodBetRecordContract.Presenter {

    public LotteryPeriodBetRecordPresenter(LotteryPeriodBetRecordContract.View view) {
        super(view);
    }

    @Override
    public LotteryPeriodBetRecordContract.View getView() {
        return ((LotteryPeriodBetRecordContract.View) mView);
    }

    @Override
    public void onLoadData(Map<String, Object> params, int page) {
        addSubscription(DataManager.getInstance().getLotteryRepo().getLotteryBetRecord(params, page), new BaseObserver<PageResult<LotteryBetRecord>>() {
            @Override
            public void onNext(PageResult<LotteryBetRecord> response) {
                getView().onDataLoaded(response);
            }

            @Override
            public void onError(Throwable e) {
                getView().onError(e);
            }
        });
    }

}
